package interview;

public class interview_01_07 {
    public void rotate(int[][] matrix) {
        int m= matrix.length;
        if(m==0) return;
        int n=matrix[0].length;
        for(int i=0;i<m;++i){
            int left=0;
            int right=n-1;
            while(left<right){
                int tmp=matrix[i][left];
                matrix[i][left]=matrix[i][right];
                matrix[i][right]=tmp;
                left++;right--;
            }
        }
        for(int i=0;i<m;++i){
            for(int j=0;j<n;++j){
                if(i+j<n-1){
                    int tmp=matrix[i][j];
                    matrix[i][j]=matrix[n-1-j][n-1-i];
                    matrix[n-1-j][n-1-i]=tmp;
                }
            }
        }
        return;
    }
}
